<template>
     <div class="mod-room">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
            <el-form-item>
                <el-input v-model="dataForm.realName" placeholder="真实姓名" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.identityCard" placeholder="身份证号" clearable></el-input>
            </el-form-item>
            <!--小区-->
            <el-form-item label="小区" v-if="superAdmin == 1">
               <el-cascader v-model="housEasteAddress" ref="housing" :options="housEasteOptions" @active-item-change="getHousEaste" :props="housEasteProps"></el-cascader>
            </el-form-item>
            <el-form-item label="楼栋">
               <el-cascader v-model="buildingAddress" ref="building" :options="buildingOptions" @active-item-change="getbuilding" :props="buildingProps"></el-cascader>
            </el-form-item>

            <el-form-item>
                <!-- <el-input v-model="dataForm.gender" placeholder="性别" clearable></el-input> -->
                <el-select v-model="dataForm.gender" placeholder="请选择">
                    <el-option
                    v-for="item in genderOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.phone" placeholder="手机号" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="getDataList()">{{ $t('handle.search') }}</el-button>
                <el-button  type="primary" @click="addOrUpdateHandle()">{{ $t('handle.add') }}</el-button>
                <el-button  type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">{{ $t('handle.batchDelete') }}</el-button>
            </el-form-item>
            </el-form>
        <el-table
            :data="dataList"
            border
            @selection-change="selectionChangeHandle"
            v-loading="dataListLoading"
            style="width: 100%;">
            <el-table-column
                type="selection"
                header-align="center"
                align="center"
                width="50">
            </el-table-column>
            <el-table-column
                fixed
                v-if='show'
                prop="id"
                header-align="center"
                align="center"
                width="80"
                label="ID">
            </el-table-column>
            <el-table-column
                fixed
                type="index"
               :label="$t('tabble.No')"
                width="50"
                :index="indexMethod">
            </el-table-column>

            <!-- <el-table-column
                prop="householderName"
                header-align="center"
                align="center"
                label="户主姓名">
            </el-table-column> -->

            <!-- <el-table-column
                prop="houseAddress"
                header-align="center"
                align="center"
                label="家庭地址">
            </el-table-column> -->

            <!-- <el-table-column
                prop="landlordName"
                header-align="center"
                align="center"
                label="房东姓名">
            </el-table-column>
            <el-table-column
                prop="landlordPhone"
                header-align="center"
                align="center"
                label="房东电话">
            </el-table-column> -->
            <!-- <el-table-column
                prop="letDate"
                header-align="center"
                align="center"
                label="租用日期">
            </el-table-column> -->
            <el-table-column
                prop="realName"
                header-align="center"
                align="center"
                label="真实姓名">
            </el-table-column>
            <el-table-column
                prop="identityCard"
                header-align="center"
                align="center"
                label="身份证号">
            </el-table-column>
            <el-table-column
                prop="contactPhone"
                header-align="center"
                align="center"
                label="联系电话">
            </el-table-column>
            <!-- <el-table-column
                prop="relationsWithHouseholds"
                header-align="center"
                align="center"
                label="与户主关系">
                <template slot-scope="scope">
                    <span>{{householdFilter(scope.row.relationsWithHouseholds)}}</span>
                </template>
            </el-table-column> -->
            <el-table-column
                prop="gender"
                header-align="center"
                align="center"
               :label="$t('form.sex')">
                <template slot-scope="scope">
                    <span>{{genderFilter(scope.row.gender)}}</span>
                </template>
            </el-table-column>
            <!-- <el-table-column
                prop="nation"
                header-align="center"
                align="center"
                label="民族">
                <template slot-scope="scope">
                    <span>{{nationFilter(scope.row.nation)}}</span>
                </template>
            </el-table-column> -->
            <!-- <el-table-column
                prop="birthdate"
                header-align="center"
                align="center"
                :label="$t('form.birthDate')">
            </el-table-column> -->
            <!-- <el-table-column
                prop="maritalStatus"
                header-align="center"
                align="center"
                label="婚姻状况">
                <template slot-scope="scope">
                     <el-tag
                        :type="scope.row.maritalStatus == 1 ? 'success' : 'danger'"
                        >{{maritalFilter(scope.row.maritalStatus)}}</el-tag>
                    <span>{{maritalFilter(scope.row.maritalStatus)}}</span>
                </template>
            </el-table-column> -->
            <!-- <el-table-column
                prop="weddingDay"
                header-align="center"
                align="center"
                label="结婚日期">
            </el-table-column> -->
            <el-table-column
                prop="accountProperties"
                header-align="center"
                align="center"
                label="户口性质">
                <template slot-scope="scope">
                    <span>{{accountPropertiesFilter(scope.row.accountProperties)}}</span>
                </template>
            </el-table-column>
            <!-- <el-table-column
                prop="domicileAddress"
                header-align="center"
                align="center"
                label="户籍地说明">
            </el-table-column> -->

            <!-- <el-table-column
                prop="healthCondition"
                header-align="center"
                align="center"
                label="健康状况">
                <template slot-scope="scope">
                    <span>{{healthFilter(scope.row.healthCondition)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="educationDegree"
                header-align="center"
                align="center"
                label="文化程度">
                <template slot-scope="scope">
                    <span>{{educationFilter(scope.row.educationDegree)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="isOnly"
                header-align="center"
                align="center"
                label="是否独生">
                <template slot-scope="scope">
                    <span>{{isOnlyFilter(scope.row.isOnly)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="occupation"
                header-align="center"
                align="center"
                label="职业">
                 <template slot-scope="scope">
                    <span>{{occupationFilter(scope.row.occupation)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="workUnit"
                header-align="center"
                align="center"
                label="工作单位">
            </el-table-column>
            <el-table-column
                prop="isWithDoor"
                header-align="center"
                align="center"
                label="是否同户">
                <template slot-scope="scope">
                    <span>{{isWithDoorFilter(scope.row.isWithDoor)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="isPartyMember"
                header-align="center"
                align="center"
                label="是否党员">
                <template slot-scope="scope">
                    <span>{{isPartyMemberFilter(scope.row.isPartyMember)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="isSubsistenceAllowance"
                header-align="center"
                align="center"
                label="是否低保人员">
                <template slot-scope="scope">
                    <span>{{subsistenceAllowanceFilter(scope.row.isSubsistenceAllowance)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="isFocusGroups"
                header-align="center"
                align="center"
                label="是否重点人群">
                <template slot-scope="scope">
                    <span>{{isFocusGroupsFilter(scope.row.isFocusGroups)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="isEndowmentInsurance"
                header-align="center"
                align="center"
                label="是否缴纳养老保险">
                <template slot-scope="scope">
                    <span>{{isEndowmentInsuranceFilter(scope.row.isEndowmentInsurance)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="disabilityType"
                header-align="center"
                align="center"
                label="残疾类型">
                <template slot-scope="scope">
                    <span>{{disabilityTypeFilter(scope.row.disabilityType)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="disabilityNumber"
                header-align="center"
                align="center"
                label="残疾证号">
            </el-table-column>
            <el-table-column
                prop="isNowMilitaryService"
                header-align="center"
                align="center"
                label="是否现服兵役">
                <template slot-scope="scope">
                    <span>{{isNowMilitaryServiceFilter(scope.row.isNowMilitaryService)}}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="isEmptyNest"
                header-align="center"
                align="center"
                label="是否空巢/孤老">
                <template slot-scope="scope">
                    <span>{{isEmptyNestFilter(scope.row.isEmptyNest)}}</span>
                </template>
            </el-table-column> -->
            <!-- <el-table-column
                prop="delFlag"
                header-align="center"
                align="center"
                label="是否删除">
                <template slot-scope="scope">
                    <span>{{delFlagFilter(scope.row.delFlag)}}</span>
                </template>
            </el-table-column> -->
            <el-table-column
                fixed="right"
                header-align="center"
                align="center"
                width="150"
                :label="$t('handle.handle')">
                <template slot-scope="scope">
                <el-button  type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('handle.update') }}</el-button>
                <el-button  type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('handle.delete') }}</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList()"></add-or-update>
  </div>
</template>
<script>
 import AddOrUpdate from './personnelBasic-add-or-update'
 import { isAuth } from '@/utils'
export default {
    data(){
        return {
            superAdmin: sessionStorage.getItem("superAdmin"),
            dataForm: {
                realName: '',
                identityCard: '',
                buildingId: '',
                housIngId: '',
                gender:'',
                phone: ''
            },
            dataList: [],
            genderOptions: [{
                value: '1',
                label: '男'
            },
            {
                value: '2',
                label: '女'
            }],
            pageIndex: 1,
            pageSize: 10,
            totalPage: 0,
            dataListLoading: false,
            dataListSelections: [],
            addOrUpdateVisible: false,
            show: false,
            householdDicts: [],
            householdDictType: {1: '父子'},
            genderDicts: [],
            genderDictType: {1: '男'},
            nationDicts: [],
            nationDictType: {1: '汉族'},
            maritalDicts: [],
            maritalDictType:{1: '未婚'},
            accountPropertiesDicts: [],
            accountPropertiesDictType:{1:"农业户口"},
            healthDicts: [],
            healthDictType: {1: '健康'},
            educationDicts: [],
            educationDictType: {1:'博士'},
            isOnlyDicts: [],
            isOnlyDictType: {1:'是'},
            occupationDicts: [],
            occupationDictType: {1: '企业、事业单位负责人'},
            isWithDoorDicts: [],
            isWithDoorDictType: {1:'是'},
            isPartyMemberDicts: [],
            isPartyMemberDecitType: {1:'是'},
            subsistenceAllowanceDicts: [],
            subsistenceAllowanceDictType: {1: '是'},
            isFocusGroupsDicts: [],
            isFocusGroupsDictType: {1:'是'},
            endowmentInsuranceDicts: [],
            endowmentInsuranceDictType: {1:'是'},
            disabilityTypeDixts: [],
            disabilityTypeDictType: {9: '无残疾'},
            nowMilitaryServiceDicts: [],
            nowMilitaryServiceDictType: {1:'是'},
            emptyNestDicts: [],
            emptyNestDictType: {1:'空巢老人'},
            delFlagDicts: [],
            delFlagDictType: {1:'未删除'},
            housEasteAddress: [],
            housEasteOptions: [],
            housEasteProps: {
                value: "id",
                label: "name",
                children: "children"
            },
            buildingAddress: [],
            buildingOptions: [],
            buildingProps: {
                value: "id",
                label: "name",
                children: "children"
            },
        }
    },
    // 获取字典
    computed: {
        // 与户主关系
        householdFilter(){
            return function(type){
                return this.householdDictType[type]
            }
        },
        // 性别
        genderFilter(){
            return function(type){
                return this.genderDictType[type]
            }
        },
        // 民族
        nationFilter(){
            return function(type){
                return this.nationDictType[type]
            }
        },
        // 婚姻状况
        maritalFilter(){
            return function(type){
                return this.maritalDictType[type]
            }
        },
        // 户口性质
        accountPropertiesFilter(){
            return function(type){
                return this.accountPropertiesDictType[type]
            }
        },
        // 健康状况
        healthFilter(){
            return function(type){
                return this.healthDictType[type]
            }
        },
        // 文化程度
        educationFilter(){
            return function(type){
                return this.educationDictType[type]
            }
        },
        // 是否独生
        isOnlyFilter(){
            return function(type){
                return this.isOnlyDictType[type]
            }
        },
        // 职业
        occupationFilter(){
            return function(type){
                return this.occupationDictType[type]
            }
        },
        // 是否同户
        isWithDoorFilter(){
            return function(type){
                return this.isWithDoorDictType[type]
            }
        },
        // 党员
        isPartyMemberFilter(){
            return function(type){
                return this.isPartyMemberDecitType[type]
            }
        },
        // 低保人员
        subsistenceAllowanceFilter(){
            return function(type){
                return this.subsistenceAllowanceDictType[type]
            }
        },
        // 重点人员
        isFocusGroupsFilter(){
            return function(type){
                return this.isFocusGroupsDictType[type]
            }
        },
        // 养老保险
        isEndowmentInsuranceFilter(){
            return function(type){
                return this.endowmentInsuranceDictType[type]
            }
        },
        // 残疾类型
        disabilityTypeFilter(){
            return function(type){
                return this.disabilityTypeDictType[type]
            }
        },
        // 兵役
        isNowMilitaryServiceFilter(){
            return function(type){
                return this.nowMilitaryServiceDictType[type]
            }
        },
        // 空巢孤寡
        isEmptyNestFilter(){
            return function(type){
                return this.emptyNestDictType[type]
            }
        },
        delFlagFilter(){
            return function(type){
                return this.delFlagDictType[type]
            }
        }
    },

    created(){
       this.getIsPartyMember()
       this.getSubsistenceAllowance()
       this.getHousehold()
       this.getGender()
       this.getNation()
       this.getMarital()
       this.getAccountProperties()
       this.getHealth()
       this.getEducation()
       this.getIsOnly()
       this.getOccupation()
       this.getIsWithDoor()
       this.getFocusGroups()
       this.getEndowmentInsurance()
       this.getDisabilityType()
       this.getNowMilitaryService()
       this.getEmptyNest()
       this.getDelFlag()
    },
    activated(){
        if(this.superAdmin === 1){
            this.getOne()
        }
        this.getDataList()
        this.getCountry()
    },
     // 引入的组件
    components: {
      AddOrUpdate
    },
    methods: {
        // 小区选择
        getHousEaste(val){
            if(val.length === 1){// 获取省
                this.getTwo(val[0])
            }else if(val.length === 2){// 市
                this.getThree(val[0],val[1])
            }else if(val.length === 3){// 区
                this.getFour(val[0],val[1],val[2])
            }else if(val.length === 4){
                this.getFive(val[0],val[1],val[2],val[3]) //社区
            }else if(val.length === 5){
                this.getSix(val[0],val[1],val[2],val[3],val[4])// 小区
            }
        },
        // 楼栋
        getbuilding(val){
            if(val.length === 1){
                this.getProvice(val[0])
            }else if(val.length === 2){
                this.getCity(val[0],val[1])
            }else if(val.length === 3){
                this.getArea(val[0],val[1],val[2])
            }else if(val.length === 4){
                this.getCommunty(val[0],val[1],val[2],val[3])
            }else if(val.length === 5){
                this.getHousing(val[0],val[1],val[2],val[3],val[4])
            }else if(val.length === 6){
                this.getBuild(val[0],val[1],val[2],val[3],val[4],val[5])
            }
        },
        getCountry(){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: 0,type:11}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                    this.buildingOptions = data.data

                }
            })
        },
        getProvice(countryId){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: countryId,type:12}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                   this.buildingOptions.map(item=>{
                       if(item.id === countryId){
                           item.children = data.data
                       }
                   })
                }
            })
        },
        getCity(countryId,provinceId){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: provinceId,type:13}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                   this.buildingOptions.map((item, i) => {
                        if (item.id === countryId) {
                            item.children.map((city, id) => {
                                 city.children = data.data;
                            });
                        }
                    });
                }
            })
        },
        getArea(countryId,provinceId,cityId){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: cityId,type:31}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                    this.buildingOptions.map((item, i) => {
                        if (item.id === countryId) {
                        item.children.map((provice, idx) => {
                            if(provice.id === provinceId){
                                provice.children.map((city, ids) => {
                                    city.children = data.data
                                });
                            }
                        });
                        }
                    });
                }

            })
        },
        getCommunty(countryId,provinceId,cityId,areaId){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: areaId,type:32}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                    this.buildingOptions.map((item, i) => {
                        if (item.id === countryId) {
                        item.children.map((provice, idx) => {
                            if(provice.id === provinceId){
                                provice.children.map((city, ids) => {
                                  if(city.id === cityId){
                                    city.children.map((area,aid)=>{
                                      area.children =data.data
                                    })
                                  }
                                });
                            }
                        });
                        }
                    });
                }
            })
        },
        getHousing(countryId,provinceId,cityId,areaId,communityCodeId){
            this.$http({
                url: `/dg-ic/ic/housing-estate/getByCommuntId/${communityCodeId}`,
                method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                    this.buildingOptions.map((item, i) => {
                        if (item.id === countryId) {
                        item.children.map((provice, idx) => {
                            if(provice.id === provinceId){
                                provice.children.map((city, ids) => {
                                    if(city.id === cityId){
                                        city.children.map((area,aid)=>{
                                            if(area.id === areaId){
                                                area.children.map((communt,ic)=>{
                                                    communt.children = data.data
                                                })
                                            }
                                        })
                                    }
                                });
                            }
                        });
                        }
                    });
                }

            })
        },
        getBuild(countryId,provinceId,cityId,areaId,communityCodeId,housId){
            this.$http({
                url: `/dg-ic/ic/building/getByHousing/${housId}`,
                method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        // this.$set(item, "children", []);
                    });
                    this.buildingOptions.map((item, i) => {
                        if (item.id === countryId) {
                        item.children.map((provice, idx) => {
                            if(provice.id === provinceId){
                                provice.children.map((city, ids) => {
                                    if(city.id === cityId){
                                        city.children.map((area,aid)=>{
                                            if(area.id === areaId){
                                                area.children.map((communt,ic)=>{
                                                    if(communt.id === communityCodeId){
                                                        communt.children.map((house,iu)=>{
                                                           house.children = data.data
                                                        })
                                                    }
                                                })
                                            }
                                        })
                                    }
                                });
                            }
                        });
                        }
                    });
                }

            })
        },
        // 一级
        getOne(){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: 0,type:11}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                    this.housEasteOptions = data.data

                }
            })
        },
        // 二级
        getTwo(countryId){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: countryId,type:12}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                   this.housEasteOptions.map(item=>{
                       if(item.id === countryId){
                           item.children = data.data
                       }
                   })
                }
            })
        },
        getThree(countryId,provinceId){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: provinceId,type:13}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                   this.housEasteOptions.map((item, i) => {
                        if (item.id === countryId) {
                            item.children.map((city, id) => {
                                 city.children = data.data;
                            });
                        }
                    });
                }
            })
        },
        getFour(countryId,provinceId,cityId){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: cityId,type:31}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                    this.housEasteOptions.map((item, i) => {
                        if (item.id === countryId) {
                        item.children.map((provice, idx) => {
                            if(provice.id === provinceId){
                                provice.children.map((city, ids) => {
                                    city.children = data.data
                                });
                            }
                        });
                        }
                    });
                }

            })
        },
        getFive(countryId,provinceId,cityId,areaId){
            this.$http({
                url: `/dg-standard-info/dgstandardaddress/childlistbyparentandtype`,
                method: 'post',
                params:{parentId: areaId,type:32}
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        this.$set(item, "children", []);
                    });
                    this.housEasteOptions.map((item, i) => {
                        if (item.id === countryId) {
                        item.children.map((provice, idx) => {
                            if(provice.id === provinceId){
                                provice.children.map((city, ids) => {
                                  if(city.id === cityId){
                                    city.children.map((area,aid)=>{
                                      area.children =data.data
                                    })
                                  }
                                });
                            }
                        });
                        }
                    });
                }
            })
        },
        getSix(countryId,provinceId,cityId,areaId,communityCodeId){
            this.$http({
                url: `/dg-ic/ic/housing-estate/getByCommuntId/${communityCodeId}`,
                method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                    data.data.map(item => {
                        this.$set(item, "name", item.name);
                        // this.$set(item, "children", []);
                    });
                    this.housEasteOptions.map((item, i) => {
                        if (item.id === countryId) {
                        item.children.map((provice, idx) => {
                            if(provice.id === provinceId){
                                provice.children.map((city, ids) => {
                                    if(city.id === cityId){
                                        city.children.map((area,aid)=>{
                                            if(area.id === areaId){
                                                area.children.map((communt,ic)=>{
                                                    communt.children = data.data
                                                })
                                            }
                                        })
                                    }
                                });
                            }
                        });
                        }
                    });
                }

            })
        },
         indexMethod(index){
            return index+1
        },
        // 户主关系
        getHousehold(){
            this.$http({
            url: 'dg-ic/ic/dict/type/relations_with_households_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.householdDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.householdDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 性别
        getGender(){
           this.$http({
            url: 'dg-ic/ic/dict/type/gender_type',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.genderDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.genderDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 民族
        getNation(){
            this.$http({
            url: 'dg-ic/ic/dict/type/nation_type',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.nationDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.nationDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 婚姻状况
        getMarital(){
            this.$http({
            url: 'dg-ic/ic/dict/type/marital_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.maritalDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.maritalDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 户口性质
        getAccountProperties(){
            this.$http({
            url: 'dg-ic/ic/dict/type/account_properties_type',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.accountPropertiesDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.accountPropertiesDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 健康状况
        getHealth(){
            this.$http({
            url: 'dg-ic/ic/dict/type/health_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.healthDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.healthDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 文化程度
        getEducation(){
            this.$http({
            url: 'dg-ic/ic/dict/type/education_type',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.educationDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.educationDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 是否独生
        getIsOnly(){
            this.$http({
            url: 'dg-ic/ic/dict/type/yes_or_no_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.isOnlyDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.isOnlyDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 职业
        getOccupation(){
            this.$http({
            url: 'dg-ic/ic/dict/type/occupation_type',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.occupationDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.occupationDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 同户
        getIsWithDoor(){
            this.$http({
            url: 'dg-ic/ic/dict/type/yes_or_no_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.isWithDoorDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.isWithDoorDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 党员
        getIsPartyMember(){
            this.$http({
            url: 'dg-ic/ic/dict/type/yes_or_no_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.isPartyMemberDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.isPartyMemberDecitType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 低保
        getSubsistenceAllowance(){
            this.$http({
            url: 'dg-ic/ic/dict/type/yes_or_no_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.subsistenceAllowanceDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.subsistenceAllowanceDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 重点
        getFocusGroups(){
            this.$http({
            url: 'dg-ic/ic/dict/type/yes_or_no_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.isFocusGroupsDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.isFocusGroupsDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 养老
        getEndowmentInsurance(){
            this.$http({
            url: 'dg-ic/ic/dict/type/yes_or_no_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.endowmentInsuranceDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.endowmentInsuranceDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 残疾类型
        getDisabilityType(){
            this.$http({
            url: 'dg-ic/ic/dict/type/disability_type',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.disabilityTypeDixts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.disabilityTypeDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        // 兵役
        getNowMilitaryService(){
            this.$http({
            url: 'dg-ic/ic/dict/type/yes_or_no_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.nowMilitaryServiceDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.nowMilitaryServiceDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        getEmptyNest(){
            this.$http({
            url: 'dg-ic/ic/dict/type/empty_type',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.emptyNestDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.emptyNestDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        getDelFlag(){
            this.$http({
            url: 'dg-ic/ic/dict/type/del_status',
            method: 'get'
            }).then(({data})=>{
                if(data && data.code === 0){
                this.delFlagDicts = data.data;
                for(let i = 0; i < data.data.length; i++){
                    this.delFlagDictType[data.data[i].value] = data.data[i].label;
                };
                }
            })
        },
        getDataList(){
            this.dataListLoading = true
            this.$http({
                url: `/dg-ic/ic/personnel-basic/list`,
                method: 'get',
                params: this.$http.adornParams({
                'page': this.pageIndex,
                'limit': this.pageSize,
                'realName': this.dataForm.realName,
                'identityCard': this.dataForm.identityCard,
                'buildingId': this.dataForm.buildingId,
                'housIngId': this.housEasteAddress[this.housEasteAddress.length-1],
                'gender': this.dataForm.gender,
                'phone': this.dataForm.phone,
                'housId': sessionStorage.getItem("thiscommunityId") || ""
                })
            }).then(({data})=>{
                this.dataForm.gender = ''
                if(this.superAdmin === 0){
                    let obj = {}
                    obj.stopPropagation = () =>{}
                    this.$refs.housing.clearValue(obj)
                }
                let obj1 = {}
                obj1.stopPropagation = () =>{}
                this.$refs.building.clearValue(obj1)
                if(data && data.code === 0){
                    this.dataList = data.data.list
                    this.totalPage = data.data.totalCount
                }else{
                    this.dataList = []
                    this.totalPage = 0
                }
                this.dataListLoading = false
            })
        },
         // 每页数
        sizeChangeHandle(val){
            this.pageSize = val
            this.pageIndex = 1
            this.getDataList()
        },
         // 当前页
        currentChangeHandle(val){
            this.pageIndex = val
            this.getDataList()
        },
                // 多选
        selectionChangeHandle(val){
            this.dataListSelections = val
        },
         // 新增/修改
      addOrUpdateHandle(id){
        this.addOrUpdateVisible = true
        this.$nextTick(()=>{
          this.$refs.addOrUpdate.init(id,this.householdDicts,this.maritalDicts,this.accountPropertiesDicts,this.healthDicts,
        this.educationDicts,this.isOnlyDicts,this.occupationDicts,this.isWithDoorDicts,this.isPartyMemberDicts,this.subsistenceAllowanceDicts,
        this.isFocusGroupsDicts,this.endowmentInsuranceDicts,this.disabilityTypeDixts,this.nowMilitaryServiceDicts,this.emptyNestDicts)
        })
      },
         // 获取未删除的楼栋
        getAllBuild(){
            this.$http({
                url: `/dg-ic/ic/room/allBuildIng`,
                method: 'get',
                params: this.$http.adornParams()
            }).then(({data})=>{
                if(data && data.code === 0){
                    this.options = data.data
                }
            })
        },
        // 获取所有未删除的小区
        getAllHous(){
            this.$http({
                url: `/dg-ic/ic/building/allHous`,
                method: 'get',
                params: this.$http.adornParams()
            }).then(({data})=>{
                if(data && data.code === 0){
                    this.options2 = data.data
                }
            })
        },
                // 删除
        deleteHandle(id){
            var ids = id ? [id] : this.dataListSelections.map(item=>{
              return item.id
          })
          this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`,'提示',{
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
          }).then(()=>{
              this.$http({
                  url: `/dg-ic/ic/personnel-basic/delete`,
                  method: 'delete',
                  data: this.$http.adornData(ids,false)
              }).then(({data})=>{
                if(data && data.code === 0){
                this.$message({
                    message: '删除成功',
                    type: 'success',
                    duration: 1500,
                    onClose: ()=>{
                    this.getDataList()
                    }
                })
            }
            })
          }).catch(()=>{})
        },
    }

}
</script>

